from algorithms.large.lsgna import LSGNA
from algorithms.large.mocgde import MOCGDE

from problems.problem import Problem


class MOCGDE_GD(MOCGDE):
    def __init__(self, problem: Problem,
                 pop_size: int,
                 kwargs,
                 ):
        super().__init__(problem, pop_size, kwargs)
        self.gd: LSGNA = LSGNA(problem, pop_size, kwargs)
        self.gd.arc = self.gd.update_archive(self.population)

    def each_iteration(self):
        self.gd.arc = self.gd.update_archive(self.population + self.gd.arc)
        offspring = self.gd.grad_optimize_with_pytorch(self.population.dec)
        self.population = self.population + offspring
        super().each_iteration()
